package JZOffer;

public class TiHuanKongGe {
    class Solution {
        public String replaceSpace(StringBuffer str) {
            String ss = "%20";
            for (int i = 0; i < str.length(); i++) {
                if (str.charAt(i) == ' ') {
                    str.deleteCharAt(i);
                    str.insert(i,ss);
                }
            }
            return str.toString();
        }
    }

    Solution getSolution() {
        return new Solution();
    }

    public static void main(String args[]) {
        TiHuanKongGe c = new TiHuanKongGe();
        TiHuanKongGe.Solution s = c.getSolution();
        StringBuffer test = new StringBuffer("We are Happy");
        System.out.println(test);
        System.out.println(s.replaceSpace(test));
    }
}
